﻿using System;
using System.Text.Json.Serialization;

using Xc.Logics.AepCoap.Models;

namespace Xc.DataAccess.AepCoapCore.Models
{

    /// <summary>
    /// 批量读取平台设备数据
    /// </summary>
    public class DeviceInfoList
    {
        /// <summary>
        /// 设备ID
        /// </summary>
        [JsonPropertyName("deviceId")]
        public string DeviceId { get; set; }


        [JsonPropertyName("deviceName")]
        public string DeviceName { get; set; }
        /// <summary>
        /// 租户ID
        /// </summary>
        [JsonPropertyName("tenantId")]
        public string TenantId { get; set; }
        /// <summary>
        /// 产品ID
        /// </summary>
        [JsonPropertyName("productId")]
        public int ProductId { get; set; }
        [JsonPropertyName("imei")]
        public string IMEI { get; set; }
        [JsonPropertyName("imsi")]
        public string IMSI { get; set; }
        /// <summary>
        /// 固件版本
        /// </summary>
        [JsonPropertyName("firmwareVersion")]
        public string FirmwareVersion { get; set; }
        /// <summary>
        /// 设备状态
        /// </summary>
        [JsonPropertyName("deviceStatus")]
        public int? DeviceStatus { get; set; }
        /// <summary>
        /// 是否订阅
        /// </summary>
        [JsonPropertyName("autoObserver")]
        public int AutoObserver { get; set; }
        [JsonPropertyName("createTime")]
        public long? CreateTime { get; set; }
        [JsonPropertyName("createBy")]

        public string CreateBy { get; set; }
        [JsonPropertyName("updateTime")]
        public long? UpdateTime { get; set; }
        [JsonPropertyName("updateBy")]
        public string UpdateBy { get; set; }
        /// <summary>
        /// 设备在线状态
        /// </summary>
        [JsonPropertyName("netStatus")]
        public int? NetStatus { get; set; }
        /// <summary>
        /// /设备最后上线时间
        /// </summary>
        [JsonPropertyName("onlineAt")]
        public long? OnlineAt { get; set; }
        /// <summary>
        /// 设备最后下线时间
        /// </summary>
        [JsonPropertyName("offlineAt")]

        public long? OfflineAt { get; set; }
        [JsonIgnore]
        public string DeviceState
        {
            get
            {
                if (DeviceStatus == 0)
                {
                    return "已注册";
                }
                else if (DeviceStatus == 1)
                {
                    return "已激活";
                }
                else
                {
                    return "已注销";
                }
            }
        }

        [JsonIgnore]
        public DateTime CreateTime1
        {
            get
            {
                if (CreateTime.HasValue)
                {
                    var dd= CreateTime.Value.TicksToDateTime();
                    return dd;
                }
                else
                {
                    return DateTime.MinValue;
                }
            }
        }
        [JsonIgnore]
        public DateTime UpdateTime1
        {
            get
            {
                if (UpdateTime.HasValue)
                {
                    var dd = UpdateTime.Value.TicksToDateTime();
                    return dd;
                }
                else
                {
                    return DateTime.MinValue;
                }
            }
        }
    }

}
